package com.sunkyc.controller.system;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sunkyc.commons.annotation.ReqLog;
import com.sunkyc.commons.entity.PageQueryVo;
import com.sunkyc.commons.entity.R;
import com.sunkyc.commons.entity.TablePageData;
import com.sunkyc.framework.system.entity.SysLoginLog;
import com.sunkyc.framework.system.service.SysLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/loginLog")
@Api(tags = "登录日志前端控制器")
@RequiredArgsConstructor
public class SysLoginLogCotrller {
    private final SysLoginLogService baseService;

    @GetMapping("/list")
    @ApiOperation("登录日志分页信息")
    @SaCheckPermission("system-log-login-query")
    public R<TablePageData<SysLoginLog>> queryList(PageQueryVo pageQueryVo,SysLoginLog sysLoginLog){
        return R.ok(baseService.queryList(pageQueryVo,sysLoginLog));
    }

    @DeleteMapping
    @ApiOperation("清空登录日志")
    @SaCheckPermission("system-log-login-delete")
    @ReqLog
    public R<Void> delLoginLog(){
        return R.result(baseService.delLoginLog());
    }


}
